package taweb.flex.air.fexBrowser.display3d
{
	import alternativa.engine3d.events.MouseEvent3D;
	import alternativa.engine3d.materials.TextureMaterial;
	import alternativa.engine3d.primitives.Box;
	import alternativa.types.Texture;
	
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	
	import mx.controls.Alert;
	
	public class LinkBox extends Box
	{
		private var link:String;
		private var textLink:String;
		private var domainLink:String;
		public function LinkBox(width:Number=100, length:Number=100, height:Number=100, link:String="",textLink:String="",domainLink:String="",widthSegments:uint=1, lengthSegments:uint=1, heightSegments:uint=1, reverse:Boolean=false, triangulate:Boolean=false)
		{
			super(width, length, height, widthSegments, lengthSegments, heightSegments, reverse, triangulate);
			this.link = link;
			this.textLink = textLink;
			this.domainLink = domainLink;
			init();
		}
		
		private function init():void{
			appliqueTexture();
		}
		
		private function appliqueTexture():void{
			var sprite:Sprite = new Sprite();
			sprite.height=20;
			sprite.width=20;
			var text:TextField = new TextField();
			text.multiline = true;
			text.text=this.domainLink+"\n\n"+this.textLink+"\n"+this.link;
			text.autoSize = TextFieldAutoSize.LEFT;
			sprite.addChild(text);
			var texture:Texture = new Texture(new BitmapData(300,300,false));
			texture.bitmapData.draw(sprite);
			var material:TextureMaterial = new TextureMaterial(texture,1,true,true);
			this.cloneMaterialToAllSurfaces(material);
		}
		
		public function get getLink():String
		{
			return this.link;
		}
	}
}